$(document).ready(function(){

    $('#tree').lightTreeview({collapse: true});

    $.lightTreeview.close('#tree ul')

    // 权限设置弹出层
    $( "#dialog" ).dialog({
        autoOpen: false,
        height: 350,
        width: 650,
        modal: true,
        buttons: {
        },
        close: function() {
            $( this ).dialog( "close" );
        }
    });

    // 设置(权限)权限链接
    $("#set_parent").click(function(){
        $( "#dialog" ).dialog( "open" );
    });

    $(".chose").click(function(){
        if (confirm('确定选择'+$(this).text()+'?')) {
            $( "#dialog" ).dialog( "close" );
            $("#p_kind_name").val($(this).text());
            $("#parent_id").val($(this).attr('value'));
            $("#p_kind_code").val($(this).attr('kind_code'));
            $("#kind_code").val($(this).attr('max_code'));
        }
    });

    $("#submit").click(function(){
        var kind_name = $("#kind_name").val();
        if (kind_name=='') {
            alert('请输入类型名称！');
            $("#kind_name").focus();
            return false;
        }
    });
});